using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using NetWorkMsg;

// 网关模块
namespace NetMsg.Gate
{
    public struct HeartQ : IServerCallbackable
    {
        
        public uint UnPackableId => 0;
        public uint PackableId => 0;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 0u);
        }
    }
    
    public struct HeartP : IUnPackable
    {
        public int TimeStamp;
        
        public const uint Sid = 0;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            TimeStamp = (int)var0;
        }
    }
    
    // 登录
    public class LoginQ : IServerCallbackable
    {
        // 帐号
        public string Account;
        public int TimeStamp;
        // 标记
        public string Token;
        
        public uint UnPackableId => 1;
        public uint PackableId => 1;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 1u);
            PackAuxiliary.Write(stream, Account);
            PackAuxiliary.Write(stream, (uint)TimeStamp);
            PackAuxiliary.Write(stream, Token);
        }
    }
    
    public enum LoginResult
    {
        //成功
        Success,
        //超时
        Timeout,
        //Token无效
        InvalidToken,
        //帐号不存在
        NotExists,
    }
    
    public struct LoginP : IUnPackable
    {
        public LoginResult Result;
        
        public const uint Sid = 1;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (LoginResult)var0;
        }
    }
    
    // 性别
    public enum Sex
    {
        Female,
        Male,
    }
    
    // 创建帐号
    public class CreateQ : IServerCallbackable
    {
        public string Account;
        public string Name;
        public Sex Sex;
        
        public uint UnPackableId => 2;
        public uint PackableId => 2;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 2u);
            PackAuxiliary.Write(stream, Account);
            PackAuxiliary.Write(stream, Name);
            PackAuxiliary.Write(stream, (uint)Sex);
        }
    }
    
    public enum CreateResult
    {
        Succ,
        // 重复创建
        Again,
    }
    
    // 创建结果
    public struct CreateP : IUnPackable
    {
        public CreateResult Result;
        public long PlayerId;
        
        public const uint Sid = 2;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (CreateResult)var0;
            UnPackAuxiliary.Read(stream, out ulong var1);
            PlayerId = (long)var1;
        }
    }
    
    // 退出登录
    public struct UnLoginQ : IIdPackable
    {
        
        public uint PackableId => 3;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 3u);
        }
    }
    
    // 因为异地登录而被踢掉
    public struct KickByReloginP : IUnPackable
    {
        
        public const uint Sid = 3;
        
        public void UnPack(MemoryStream stream)
        {
        }
    }
    
    public enum GateEnum
    {
        HeartP,
        LoginP,
        CreateP,
        KickByReloginP,
    }
}
